<template>
  <div class="labor-card" :class="{ 'checked': checked }">
    <div class="card-header">
      <h3>{{ title }}</h3>
    </div>

    <div class="date-range">
      {{ startDate }} - {{ endDate }}
    </div>

    <div class="check-button-container">
      <el-button
          class="check-button"
          :type="checked ? 'primary' : ''"
          circle
          @click.stop="$emit('check')"
      >
        {{ checked ? '已打卡' : '未打卡' }}
      </el-button>
    </div>

    <div class="progress-text">
      已打卡 {{ checkedDays }}/{{ totalDays }} 天
    </div>
  </div>
</template>

<script setup lang="ts">
defineProps({
  title: {
    type: String,
    required: true
  },
  startDate: {
    type: String,
    required: true
  },
  endDate: {
    type: String,
    required: true
  },
  checked: {
    type: Boolean,
    default: false
  },
  totalDays: {
    type: Number,
    required: true
  },
  checkedDays: {
    type: Number,
    required: true
  }
});

defineEmits(['check']);
</script>

<style scoped>
.labor-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s;
  height: 220px;
}

.labor-card.checked {
  border: 1px solid var(--el-color-primary-light-5);
}

.card-header h3 {
  margin: 0;
  font-size: 16px;
  color: #333;
  text-align: center;
}

.date-range {
  margin: 10px 0;
  font-size: 14px;
  color: #606266;
  text-align: center;
}

.check-button-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.check-button {
  width: 80px; /* 稍微加宽以适应文字 */
  height: 80px;
  font-size: 16px;
  white-space: normal;
  line-height: 1.4;
  word-break: keep-all;
}

.check-button:not(.el-button--primary) {
  color: var(--el-color-danger);
  border-color: var(--el-color-danger-light-5);
}

.progress-text {
  margin-top: 10px;
  font-size: 14px;
  color: #909399;
  text-align: center;
}
</style>
